""" Get the price coefficient moments for estimation in SMM

"""
import pandas as pd
import numpy as np
import json
import sys
sys.path.append('./')
from src.run_scripts import utils

#%% IMPORT DATA -------------------------------------------------------------------------
df_contracts = pd.read_csv('./data_py/processed/contracts_final.csv', index_col=[0])
delta = pd.read_csv('./models/smm_input/delta.csv', index_col=[0]).values[0][0]

for t in ['month', 'fortnight']:
    price_match_values_by_spec = dict()
    for spec in ['low', 'mid', 'high']:
        price_match_values_by_spec[spec] = dict()
        with open(f"./models/price_match/price_match_values_{spec}_3_{t}.json") as f:
            price_match_values_by_spec[spec] = np.array(json.load(f))

    coefs_data = utils.get_price_coefficients(df_contracts, price_match_values_by_spec, delta)

    pd.Series(coefs_data).to_csv(f'./models/price_match/coefs_data_{t}.csv')
    pd.Series(coefs_data).to_csv(f'./models/smm_input/coefs_data_{t}.csv')
